package core.hmxchen.log.formatter;

import core.hmxchen.log.LogFormatter;
import core.hmxchen.log.entity.MethodInfo;
import core.hmxchen.log.enums.Level;
import core.hmxchen.log.handler.LogHandler;
import org.slf4j.Logger;

/**
 * @program: log-print
 * @description: 环绕日志格式化
 * @author: hmxchen
 * @create: 2021-09-03 14:43
 **/
public class AroundLogPrintFormatter implements LogFormatter {
    @Override
    public void format(Logger log, Level level, String busName, MethodInfo methodInfo, Object[] args, String[] filterParamNames, Object result, Throwable throwable) {
        LogHandler.print(log,level,LogHandler.getAroundInfo(busName,methodInfo,args,filterParamNames,result,throwable));
        if(throwable!=null){
            log.error(throwable.getMessage(),throwable);
        }
    }
}
